package mspbots.qbd.desktop.core;

import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.time.Duration;

import static mspbots.qbd.common.RedisKeys.TENANT_FILE_PATH_REDIS_KEY;

/**
 * DesktopController
 *
 * @author <a href="https://github.com/vnobo">Alex bob</a>
 * @date Created by 2020/8/25
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("client/{tenantId}")
public class DesktopController {

    private final StringRedisTemplate stringRedisTemplate;

    @GetMapping("sync-file-path")
    public Boolean syncPath(@PathVariable Long tenantId, @RequestParam String path) {
        this.stringRedisTemplate.opsForValue()
                .set(TENANT_FILE_PATH_REDIS_KEY + tenantId, path
                        , Duration.ofDays(3600));
        return true;
    }

}
